<template>
	<view v-if="is_store == 1 || is_store == 2">
		<!-- gc_school/pages/shop/my.wxml -->
		<cu-custom class="bgmains" bgColor="bgmains" :isBack="true">
			<view slot="content">我的小店</view>
		</cu-custom>
		<!-- style="filter: blur(4rpx);" :style="[{ backgroundImage:'url(' +data.info.business_image + ')' }]" -->
		<view>
			<image style="filter: blur(12rpx);height: 700rpx;position: relative;width: 100%;"
				:src="data.info.business_image" mode="aspectFill"></image>
			<view class="main">
				<image class="avatar" :src="data.info.business_image" mode="scaleToFill" />
				<view class="name margin-top margin-bottom-xs">{{data.info.business_name}}
					<!-- v-if="is_store==1" -->
					<!-- <image  class="margin-left-sm" :src="fileUrl+'store/edit.png'" style="width: 30rpx;height: 30rpx;" @click="go('/gc_school/pages/shop/info')"></image> -->
				</view>
				<view class="zi">所属学院：{{data.school_name?data.school_name:'学校不存在' }}</view>
				<!-- <view class="zi">到期时间：{{data.expire_time}}</view> -->
				<view class="price_info padding">
					<view class="row">
						<view @click="go('/gc_school/pages/shop/balancelog')">
							<view class="key">我的余额（元）</view>
							<view class="val margin-top-xs">{{data.store_balance}}</view>
						</view>
						<view class="tx_btn" @click="go('/gc_school/pages/shop/tixian')" v-if="is_store == 1">提现</view>
					</view>
					<view class="tj row margin-top-lg">
						<view class="flex-col" @click="go('/gc_school/pages/shop/order')">
							<view class="key">今日订单</view>
							<view class="val">{{data.order_day_num||0}}</view>
						</view>
						<view class="flex-col" @click="go('/gc_school/pages/shop/order')">
							<view class="key">总订单</view>
							<view class="val">{{data.order_num||0}}</view>
						</view>
						<view class="flex-col padding-right" @click="go('/gc_school/pages/shop/beanlog')"
							v-if="data.store_bean_switch==1">
							<view class="key">金豆</view>
							<view class="val">{{data.info.balance}}</view>
							<!-- <view class="text-lg text-red">（提现受限）</view> -->
						</view>
					</view>
				</view>
			</view>
		</view>

		<!-- <view class="title text-center text-lg">欢迎您，老潼关肉夹馍</view> -->
		<view class="tit padding-left margin-top">常用功能</view>
		<view class="nav_list padding" :style="show==true?'padding-bottom: 300rpx;':''">
			<view class="nav row padding" @click="go('/gc_school/pages/shop/info')">
				<image class="icon lg  cuIcon-comment" style="font-weight: 900;" :src="item.icon" mode="scaleToFill" />
				店铺设置
				<view class="cuIcon-right"></view>
			</view>
			<block v-for="(item,index) in navList" :key="index">
				<view class="nav row padding" @click="go(item.url+'?id='+id)"
					v-if="(index==0&&data.store_bean_switch==1)||index>0">
					<image class="icon" :src="item.icon" mode="scaleToFill" />
					{{item.name}}
					<view class="cuIcon-right"></view>
				</view>
			</block>
			<view class="nav row padding" @click="scan()">
				<image class="icon lg  cuIcon-scan" style="font-weight: 900;" :src="item.icon" mode="scaleToFill" />
				到店核销
				<view class="cuIcon-right"></view>
			</view>


			<view class="nav row padding" @click="go('/uni_modules/school-comment/pages/list/list?b_id='+ id)">
				<image class="icon lg  cuIcon-comment" style="font-weight: 900;" :src="item.icon" mode="scaleToFill" />
				评论管理
				<view class="cuIcon-right"></view>
			</view>



			<!-- <view class="nav row padding" @click="dianyuan" v-if="is_store==1">
                <image  class="icon lg cuIcon-profile"
                    style="font-weight: 900;"
                    mode="scaleToFill"
                />
                店员管理
                <view class="cuIcon-right"></view>
            </view> -->
		</view>






		<view class="notice_fixed padding-sm" v-if="show&&data.store_bean_switch==1">
			<image class="bg" mode="widthFix" :src="fileUrl+'store/notice_bg.png'"></image>
			<view class="padding notice_con">
				<view class="flex align-center" style="width: 100%;">
					<image class="icon" :src="fileUrl+'store/icon6.png'"></image>
					<view class="text-lg titles text-bold">您的店铺金豆{{data.info.balance>0?'即将':'已'}}用完</view>
					<text class="cuIcon-close" @click="show=false"></text>
				</view>
				<view class="text-df margin-top-sm">{{data.info.balance>0?'即将影响您店铺接单收益，请尽快充值哦～':'店铺接单和商家提现会受到影响，请尽快充值哦～'}}</view>
				<view class="flex justify-end margin-top-sm">
					<view class="recharge_btn close_btn" @click="show=false">关闭</view>
					<view class="recharge_btn" @click="go('/gc_school/pages/shop/pointrecharge')">立即充值</view>
				</view>
			</view>

		</view>

	</view>
</template>

<script>
	// gc_school/pages/shop/my.js
	var app = getApp();
	import siteInfo from '@/siteinfo.js';

export default {
    data() {
        return {
            data: {
                today_count: 0,
                total_count: 0,
                total_sum: 0,
                school: '',
                store: {
                    deadtime: ''
                }
            },
            id: '',
            navList:[
                {icon: 'https://test.fkynet.net/wximage/store/icon1.png',name:"金豆充值",url:"/gc_school/pages/shop/pointrecharge"},
                // {icon: 'https://test.fkynet.net/wximage/store/icon2.png',name:"店铺管理",url:"/gc_school/pages/shop/info"},
                {icon: 'https://test.fkynet.net/wximage/store/icon3.png',name:"订单管理",url:"/gc_school/pages/shop/order"},
                {icon: 'https://test.fkynet.net/wximage/store/icon4.png',name:"分类管理",url:"/gc_school/pages/shop/cate"},
                {icon: 'https://test.fkynet.net/wximage/store/icon5.png',name:"商品管理",url:"/gc_school/pages/shop/goods"},
                { icon: 'https://test.fkynet.net/wximage/store/icon3.png', name: "优惠券管理", url: "/gc_school/pages/shop/coupon" },
                // { icon: 'https://test.fkynet.net/wximage/store/icon3.png', name: "扫码", url: "qrcode" },

				],
				show: false,
				is_store: 0,

			};
		}
		/**
		 * 生命周期函数--监听页面加载
		 */
		,
		onLoad: function(options) {
			console.log(options);
			if (options.id) {
				this.setData({
					id: options.id
				});
			}


		},
		/**
		 * 生命周期函数--监听页面初次渲染完成
		 */
		onReady: function() {},
		/**
		 * 生命周期函数--监听页面显示
		 */
		onShow: function() {
			this.getStore();
		},
		/**
		 * 生命周期函数--监听页面隐藏
		 */
		onHide: function() {},
		/**
		 * 生命周期函数--监听页面卸载
		 */
		onUnload: function() {},
		/**
		 * 页面相关事件处理函数--监听用户下拉动作
		 */
		onPullDownRefresh: function() {},
		/**
		 * 页面上拉触底事件的处理函数
		 */
		// onShareAppMessage: function () {
		// }
		onReachBottom: function() {},
		/**
		 * 用户点击右上角分享
		 */
		methods: {
			getStore() {
				var that = this;
				app.globalData.util.request({
					url: 'ZhBusinesss/index',
					method: 'GET',
					data: {
						id: this.id
					},
					success(res) {
						console.log(res.data.data.is_inform)
						// show
						that.show = res.data.data.is_inform == 1 ? true : false
						//    res.data.data.store_bean_switch=0
						that.setData({
							data: res.data.data,
							is_store: res.data.data.is_store

						});
						that.id = res.data.data.info.business_id
					}
				}, true);
			},

			jump(e) {
				console.log(e.currentTarget.dataset.url);
				console.log("qrcode?id=" + this.id);
				if (e.currentTarget.dataset.url == "qrcode?id=" + this.id) {
					this.scan()
					return
				}

				if (e.currentTarget.dataset.url) {
					uni.navigateTo({
						url: e.currentTarget.dataset.url
					});
				}
			},
			scan() {
				uni.scanCode({
					success: (res) => {
						console.log(res);
						let data = JSON.parse(res.result)
						this.tips.choose("确定核销吗？", '二次确认', "确定").then(ress => {
							if (ress.code == 200) {
								console.log(data);
								//    let app= getApp()
								//    console.log(siteInfo);
								uni.request({
									url: siteInfo.url + "Orders/confirmFinish",
									data: {
										o_id: data.oid,
										wxapp_id: siteInfo.uniacid

									},
									method: "POST",
									header: {
										'Authorization': data.userToken
									},
									success: (res) => {
										if (res.data.status == 200) {
											this.tips.success("核销成功")
											this.getStore();
										} else {
											this.tips.tips(res.data.msg)
										}
									},
									fail: (err) => {
										console.log(err);
										// return reject(err)
									}
								})
							}
						})
					}
				})

			},
			dianyuan() {
				uni.navigateTo({
					url: `/uni_modules/school-shop-admin/pages/shopAssistant/index?s_id=${this.data.info.s_id}&b_id=${this.id}`
				})
			}
		}
	};
</script>
<style lang="scss">
	/* gc_school/pages/shop/my.wxss */
	page {
		background: white !important;
	}

	.bgmains {
		color: white;
	}

	.title {
		background: white;
		margin-top: -10rpx;
		line-height: 120rpx;
		margin-bottom: 30rpx;
	}

	.list {
		margin-top: -15rpx;
		background: white;
		display: flex;
		margin-bottom: 30rpx;
		padding: 40rpx 0 20rpx;
		text-align: center;
		font-size: 30rpx;
		line-height: 60rpx;
	}

	.list_item {
		width: 50%;
		border-right: 1rpx solid #f2f2f2;
		/* border: 1rpx solid #F2F2F2; */
	}

	.list_item .num {
		font-weight: bold;
		font-size: 36rpx;
	}

	.menu {
		display: flex;
		flex-wrap: wrap;
		background: white;
	}

	.menu_item {
		text-align: center;
		font-size: 30rpx;
		width: 50%;
		border-right: 1rpx solid #f2f2f2;
		border-bottom: 1rpx solid #f2f2f2;
		padding: 50rpx 0;
	}

	.menu_item image {
		width: 95rpx;
		height: 95rpx;
		margin-bottom: 20rpx;
	}

	.notice_fixed {
		position: fixed;
		bottom: 0;
		width: 100%;

		.bg {
			width: 100%;
			border-radius: 20rpx;
		}

		.notice_con {
			position: absolute;
			top: 30rpx;
			left: 30rpx;
			width: 92%;
		}

		.icon {
			width: 50rpx;
			height: 50rpx;
			margin-right: 10rpx;
		}

		.cuIcon-close {
			font-size: 40rpx;
			font-weight: bold;
		}

		.titles {
			flex-grow: 1;
		}

		.close_btn {
			border: 2rpx solid #FF4C4D;
			background-color: white !important;
			color: #FF4C4D !important;
			margin-right: 20rpx;
		}

		.recharge_btn {
			background-color: #FF4C4D;
			width: 160rpx;
			height: 60rpx;
			line-height: 60rpx;
			border-radius: 50rpx;
			color: white;
			text-align: center;
			font-size: 24rpx;
		}
	}
</style>
<style lang="scss">
	@import "./my.scss";
</style>